package com.yuerlive.rainbow.module.mine;

import android.support.v7.widget.GridLayoutManager;
import android.support.v7.widget.RecyclerView;

import com.yuerlive.rainbow.R;
import com.yuerlive.rainbow.base.BaseActivity;
import com.yuerlive.rainbow.entity.GradleInfo;
import com.yuerlive.rainbow.module.mine.adapter.GradleAdapter;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;

/**
 * Created by Admin on 2017/5/21.
 */

public class MyGradleActivity extends BaseActivity {
    @BindView(R.id.rvGradle)
    RecyclerView recyclerView;
    GridLayoutManager manager;
    GradleAdapter adapter;
    private List<GradleInfo> infos=new ArrayList<>();

    @Override
    protected int getLayoutId() {
        return R.layout.activity_gradle2;
    }

    @Override
    protected void initViews() {
        manager = new GridLayoutManager(this, 3);
        manager.setSpanSizeLookup(new GridLayoutManager.SpanSizeLookup() {
            @Override
            public int getSpanSize(int position) {
                switch (adapter.getItemViewType(position)){
                    case GradleAdapter.HEAD:
                      return 3;
                    case GradleAdapter.ITEM:
                        return 1;
                }
                return 0;
            }
        });
        recyclerView.setLayoutManager(manager);
        adapter=new GradleAdapter(this,infos);
        recyclerView.setAdapter(adapter);
        loadData();
    }
    private void loadData(){
        infos.clear();
        for(int i=0 ;i <3 ;i++){
            GradleInfo info =new GradleInfo();
            info.setIcon("");
            info.setName("沙瑞金");
            info.setStartLevel(20);
            infos.add(info);
        }
      adapter.notifyDataSetChanged();
    }
}
